package com.tanhua.server.controller;

import com.tanhua.domain.vo.SoundVo;
import com.tanhua.server.service.SoundService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Slf4j
public class SoundController {
    @Autowired
    private SoundService soundService;
    /**
     * 发送桃花语音
     * @param soundFile
     */
    @PostMapping("/peachblossom")
    public void sendVoice(MultipartFile soundFile) throws IOException {
        log.info("soundFile {}",soundFile);
        soundService.saveSound(soundFile);
    }

    @GetMapping("/peachblossom")
    public ResponseEntity getVoice() throws IOException {
       ResponseEntity soundVo=soundService.getSound();
       return soundVo;
    }
}
